package cn.virens.util.select2;

import java.util.ArrayList;
import java.util.List;

/**
 * Select2 插件数据封装
 * @作者 :loioi
 * @创建时间 :2016年12月27日
 */
public class Select2 {
	private Object id;
	private String text;
	private List<Select2> children;

	public Object getId() {
		if (children != null && !children.isEmpty()) {
			return null;
		} else {
			return id;
		}
	}

	public void setId(Object id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public List<Select2> getChildren() {
		return children;
	}

	public void setChildren(List<Select2> children) {
		this.children = children;
	}

	public void addChildren(Select2 children) {
		if (this.children == null) this.children = new ArrayList<>();
		this.children.add(children);
	}
}
